<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Admins extends Admin_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->model("admin/admin_model");
    }
    /**
     *   登陆操作
     */
    public function index(){
        $this->load->view('admin/login');
    }

    /**
    *   登陆操作
     */
    public function login(){
        if($this->is_post()){
            $username = $this->input->post('username', true);
            $password = $this->input->post('password', true);

            if(!($this->admin_model->login( $username, $password ))) {

                cpmessage('登陆失败', 'index.php?c=admins&m=login');
            }else{

                cpmessage('登陆成功', 'index.php?d=admin&c=type');
            }
        }else{
            $this->load->view('admin/login');
        }
    }

    /**
    *   退出操作
     */
    public function logout() {
        $this->admin_model->logout();

        cpmessage('退出成功', '/index.php?c=admins&m=login');
    }



}
